//
//  DKAppcationRepayTopView.m
//  DanKU
//
//  Created by EDY on 2023/11/9.
//

#import "DKAppcationRepayTopView.h"

@interface DKAppcationRepayTopView()

@property(nonatomic,strong)UILabel *dk_OrderCountlab;
@property(nonatomic,strong)UIView *dk_OrderCellView;
@property(nonatomic,strong)UIImageView *dk_OrderIcon_BackImg;
@property(nonatomic,strong)UIImageView *dk_OrderIconImg;
@property(nonatomic,strong)UILabel *dk_OrderTitlelab;
@property(nonatomic,strong)UILabel *dk_OrderLine;
@property(nonatomic,strong)UILabel *dk_OrderDetailab;

@end

@implementation DKAppcationRepayTopView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame: frame]) {
        self.backgroundColor =  DK_Hex(@"#FAFAFA");
        [self creatUI];
    }
    return self;
}

-(void)setDataSoure:(DKOrderDetailModel *)dataSoure{
    self.dk_OrderTitlelab.text = dataSoure.productName;
    switch (dataSoure.status) {
        case 90:{
            self.dk_OrderCountlab.text = @"Under review";
        }
            break;
        case 100:{
            self.dk_OrderCountlab.text = @"Approved";
        }
            break;
        
        case 150:{
            self.dk_OrderCountlab.text = @"Issuing";
        }
            break;
            
        case 169:{
            self.dk_OrderCountlab.text = @"Issue failed";
        }
            break;
            
        case 170:{
            self.dk_OrderCountlab.text = @"Order Issued";
        }
            break;
            
        case 180:{
            self.dk_OrderCountlab.text = @"Overdue";
        }
            break;
            break;
        default:
            break;
    }
}


-(void)creatUI{
    [self addSubview:self.dk_OrderCountlab];
    [self.dk_OrderCountlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(30);
        make.right.equalTo(self).offset(-30);
        make.height.mas_equalTo(50);
        make.top.equalTo(self).offset(10);
    }];
    
    [self addSubview:self.dk_OrderCellView];
    [self.dk_OrderCellView addSubview:self.dk_OrderIcon_BackImg];
    [self.dk_OrderCellView addSubview:self.dk_OrderIconImg];
    [self.dk_OrderCellView addSubview:self.dk_OrderTitlelab];
    [self.dk_OrderCellView addSubview:self.dk_OrderLine];
    [self.dk_OrderCellView addSubview:self.dk_OrderDetailab];
    
    
    [self.dk_OrderCellView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.right.equalTo(self).offset(-15);
        make.top.equalTo(self.dk_OrderCountlab.mas_bottom);
        make.bottom.equalTo(self);
    }];
    
    [self.dk_OrderIcon_BackImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dk_OrderCellView).offset(15);
        make.width.height.mas_equalTo(38);
        make.top.equalTo(self.dk_OrderCellView).offset(7);
    }];
    
    [self.dk_OrderIconImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(22);
        make.height.mas_equalTo(26);
        make.center.equalTo(self.dk_OrderIcon_BackImg);
    }];

    [self.dk_OrderTitlelab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dk_OrderIcon_BackImg.mas_right).offset(10);
        make.width.mas_equalTo(DK_SCREEN_W/4);
        make.height.mas_equalTo(30);
        make.top.equalTo(self.dk_OrderCellView).offset(10);
    }];
    
    [self.dk_OrderLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dk_OrderCellView).offset(15);
        make.right.equalTo(self.dk_OrderCellView).offset(-15);
        make.height.mas_equalTo(0.5);
        make.top.equalTo(self.dk_OrderIcon_BackImg.mas_bottom).offset(5);
    }];
    
    [self.dk_OrderDetailab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dk_OrderIcon_BackImg);
        make.width.height.equalTo(self.dk_OrderTitlelab);
        make.top.equalTo(self.dk_OrderLine.mas_bottom).offset(20);
    }];

}

- (UILabel *)dk_OrderCountlab {
    if (!_dk_OrderCountlab) {
        _dk_OrderCountlab = [[UILabel alloc] init];
        _dk_OrderCountlab.textColor = DK_Hex(@"#333333");
        _dk_OrderCountlab.font = [UIFont boldSystemFontOfSize:18];
        _dk_OrderCountlab.text = @"Details";
    }
    return _dk_OrderCountlab;
}

-(UIView*)dk_OrderCellView{
    if (!_dk_OrderCellView) {
        _dk_OrderCellView = [[UIView alloc]init];
        _dk_OrderCellView.backgroundColor = DK_Hex(@"#FFFFFF");
        _dk_OrderCellView.layer.cornerRadius = 10;
    }
    return _dk_OrderCellView;
}

- (UIImageView*)dk_OrderIcon_BackImg{
    if (!_dk_OrderIcon_BackImg) {
        _dk_OrderIcon_BackImg = [[UIImageView alloc] init];
        _dk_OrderIcon_BackImg.image =  DK_GetImage(@"dk_order_list_back_img");
    }
    return _dk_OrderIcon_BackImg;
}

- (UIImageView*)dk_OrderIconImg{
    if (!_dk_OrderIconImg) {
        _dk_OrderIconImg = [[UIImageView alloc] init];
        _dk_OrderIconImg.image =  DK_GetImage(@"dk_order_list_img");
    }
    return _dk_OrderIconImg;
}

- (UILabel *)dk_OrderTitlelab {
    if (!_dk_OrderTitlelab) {
        _dk_OrderTitlelab = [[UILabel alloc] init];
        _dk_OrderTitlelab.textColor = DK_Hex(@"#333333");
        _dk_OrderTitlelab.font = [UIFont boldSystemFontOfSize:15];
        _dk_OrderTitlelab.text = @"Go 002";
    }
    return _dk_OrderTitlelab;
}

- (UILabel *)dk_OrderLine {
    if (!_dk_OrderLine) {
        _dk_OrderLine = [[UILabel alloc] init];
        _dk_OrderLine.backgroundColor = DK_Hex(@"#E0E0E0");
    }
    return _dk_OrderLine;
}

- (UILabel *)dk_OrderDetailab {
    if (!_dk_OrderDetailab) {
        _dk_OrderDetailab = [[UILabel alloc] init];
        _dk_OrderDetailab.textColor = DK_Hex(@"#333333");
        _dk_OrderDetailab.font = [UIFont boldSystemFontOfSize:15];
        _dk_OrderDetailab.text = @"Details";
    }
    return _dk_OrderDetailab;
}



@end
